﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ITProject.Domain.Entities;

namespace ITProject.WebUI.Models.ProjectUser
{
    public class ShowTopicProjectUserViewModel
    {
        public List<PostVM> Posts { get; set; }
        public string TopicName { get; set; }

        public string PostContent { get; set; }
        public int projectID { get; set; }

        public static void AddAutorsNames(List<PostVM> posts, List<User> users)
        {
            foreach (var item in posts)
            {
                item.AutorName = users.Where(x => x.Id == item.AutorId).FirstOrDefault().Login;
            }
        }
    }

    public class PostVM
    {
        public DateTime AddDate { get; set; }
        public string Content { get; set; }
        public string AutorName { get; set; }
        public int AutorId { get; set; }

        public static PostVM ConvertFromEntity(Post post)
        {
            PostVM vm = new PostVM();
            vm.AddDate = post.AddDate;
            vm.AutorId = post.AutorId;
            vm.Content = post.Content;
            return vm;
        }
    }
}